<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>

<div class="with-head">
	<div class="with-padding"
		style="height: 100%; overflow: auto; color: Black;">
		<div>
			<div class="block-border" style="background-color: #efefef;">
				<div class="block-content">
					<h1>
						Manage School Settings
					</h1>
					<div class="block-controls">
						<ul class="controls-tabs with-children-tip">
							<li>
								<a title="Add" href="${contextPath}/setupSchoolManagementForm.ems">
									<img src="${imagePath}/add.png"> 
								</a>
							</li>
							<li>
								<a title="Edit" href="javascript:getSchoolDetails('${applicationScope.contextPath}','schoolSelectBoxId')">
									<img src="${imagePath}/edit.png"> 
								</a>
							</li>
						</ul>
					</div>
					<fieldset class="grey-bg">
						<legend>
							<a href="#">Please Select</a>
						</legend>
						<div class="float-left gutter-right">
							<span class="label">Existing Schools</span>
							<select id="schoolSelectBoxId" name="schoolId">
								<c:forEach var="school" items="${schoolList}">
									<option value="${school.schoolId}">
										${school.schoolName}
									</option>
								</c:forEach>
							</select>
						</div>
						<div class="float-left gutter-right">
							<span class="label">&nbsp;&nbsp;</span>
							<input value="Edit" class="button" type="button" onclick="getSchoolDetails('${applicationScope.contextPath}','schoolSelectBoxId')" />
						</div>
					</fieldset>
					<br>
					<form:form action="saveSchool.ems" method="POST" commandName="school" enctype="multipart/form-data">
						<div class="box">
							<table cellpadding="3" width="100%">
								<tbody>
									<tr bgcolor="#BCDDFF">
										<td>
											<p class="mini-infos">
												<strong> 
													<span style="font-weight: 700">
														Please fill the details below to Add School
													</span> 
												</strong>
											</p>
										</td>
										<td align="right">
										</td>
									</tr>
								</tbody>
							</table>
							<table class="table" width="100%">
								<tbody>
									<tr>
										<td width="200">
											School Name
										</td>
										<td colspan="2">
											<form:hidden path="schoolId" />
											<form:input path="schoolName" maxlength="500" cssClass="tbox" cssStyle="width: 400px;" />											
										</td>
									</tr>
									<tr>
										<td>
											Short Name
										</td>
										<td colspan="2">
											<form:input path="shortName" maxlength="500" cssClass="tbox" cssStyle="width: 223px;" />
										</td>
									</tr>
									<tr>
										<td>
											School Type
										</td>
										<td colspan="2">
											<table border="0">
												<tbody>
													<tr>
														<c:forEach var="schoolType" items="${schoolTypeList}">
															<td>
																<form:radiobutton id="schoolType-${schoolType.schoolTypeId}" path="schoolTypeId" value="${schoolType.schoolTypeId}" />
																<label for="schoolType-${schoolType.schoolTypeId}">
																	${schoolType.schoolType}
																</label>
															</td>														
														</c:forEach>														
													</tr>
												</tbody>
											</table>
										</td>
									</tr>
									<tr>
										<td>
											School Level
										</td>
										<td colspan="2">
											<form:select path="schoolLevelId">
												<c:forEach var="schoolLevel" items="${schoolLevelList}">
													<form:option value="${schoolLevel.schoolLevelId}">
														${schoolLevel.schoolLevel}
													</form:option>
												</c:forEach>
											</form:select>											
										</td>
									</tr>
									<tr>
										<td>
											School Title
										</td>
										<td colspan="2">
											<form:input path="title" maxlength="500" cssClass="tbox" cssStyle="width: 400px;" />											
											<br>
											<span style="font-size: x-small">* Enter school domain
												name if you want to run schoolwebsite as a seperate
												domain/website.</span>
										</td>
									</tr>
									<tr>
										<td>
											Address
										</td>
										<td colspan="2">
											<form:input path="address" maxlength="500" cssClass="tbox" cssStyle="width: 400px;" />											
										</td>
									</tr>
									<tr>
										<td>
											Town
										</td>
										<td colspan="2">
											<form:input path="town" maxlength="100" cssClass="tbox" />											
										</td>
									</tr>
									<tr>
										<td>
											District
										</td>
										<td colspan="2">
											<form:input path="district" maxlength="100" cssClass="tbox" />											
										</td>
									</tr>
									<tr>
										<td>
											County
										</td>
										<td colspan="2">
											<form:select path="countryId">
												<c:forEach var="country" items="${countryList}">
													<form:option value="${country.countryId}">
														${country.countryName}
													</form:option>
												</c:forEach>
											</form:select>
										</td>
									</tr>
									<tr>
										<td>
											State
										</td>
										<td colspan="2">
											<form:select path="stateId">
												<c:forEach var="state" items="${stateList}">
													<form:option value="${state.stateId}">
														${state.stateName}
													</form:option>
												</c:forEach>
											</form:select>
										</td>
									</tr>									
									<tr>
										<td>
											Zip Code
										</td>
										<td colspan="2">
											<form:input path="zipCode" maxlength="50" cssClass="tbox" cssStyle="width: 223px;" />											
										</td>
									</tr>
									<tr>
										<td>
											Contact
										</td>
										<td colspan="2">
											<form:input path="contact" maxlength="500" cssClass="tbox" cssStyle="width: 323px;" />											
										</td>
									</tr>
									<tr>
										<td>
											Email
										</td>
										<td colspan="2">
											<form:input path="email" maxlength="200" cssClass="tbox" cssStyle="width: 323px;" />											
										</td>
									</tr>	
									<tr>
										<td>
											Date Format
										</td>
										<td colspan="2">
											<form:select path="dateFormatId">
												<c:forEach var="dateFormat" items="${dateFormatList}">
													<form:option value="${dateFormat.dateFormatId}">
														${dateFormat.dateFormat}
													</form:option>
												</c:forEach>
											</form:select>
										</td>
									</tr>
									<tr>
										<td>
											Logo
										</td>
										<td colspan="2">
											<input type="file" name="logoImageMulitpartFile" style="width: 400px;">											
										</td>
									</tr>
									<tr>
										<td>
											BannerImage
										</td>
										<td colspan="2">
											<input type="file" name="bannerImageMultipartFile" style="width: 400px;">
										</td>
									</tr>
									<tr>
										<td>
											School Description
										</td>
										<td colspan="2">
											<div>
												<form:textarea path="schoolDescription"/>												
											</div>
										</td>
									</tr>
									<tr>
										<td>
											&nbsp;
										</td>
										<td colspan="2">
											<input value="Save" class="button" type="submit">
											&nbsp; &nbsp;
											<c:choose>
												<c:when test="${requestScope.school.schoolId == 0}">
													<input value="Save" class="button" type="submit">
												</c:when>
												<c:otherwise>
													<input value="Update" class="button" type="submit">
													&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
													<input value="Delete" class="button" type="button" onclick="deleteClass('${applicationScope.contextPath}','${requestScope.school.schoolId}')">
												</c:otherwise>
											</c:choose>
										</td>										
									</tr>
								</tbody>
							</table>
						</div>
					</form:form>
				</div>
			</div>
		</div>
	</div>
</div>